package com.itheima.exer.homework.hw1009;

import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

/**
 * 3,5,4,7,12,9,10,1
 */
public class NumberTest3 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(new File("exercises\\c.txt")));
        String s = br.readLine();
        String[] split = s.split(",");
        Set<Integer> set = new TreeSet<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                int i = o1 - o2;
                return i;
            }
        });
        for (int i = 0; i < split.length; i++) {
            int i1 = Integer.parseInt(split[i]);
            set.add(i1);
        }
        String s1 = set.toString();
        String s2 = s1.substring(1, s1.length() - 1);
        BufferedWriter bw = new BufferedWriter(new FileWriter(new File("exercises\\c.txt")));
        bw.write(s2);
        br.close();
        bw.close();
    }
}
